<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.tisson.pojo.Page"%>
<%@ page import="com.tisson.pojo.Admin"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <script type="text/javascript">
function document.onkeydown()                //网页内按下回车触发
{
 if(event.keyCode==13)    //回车键监听
 {
	goto();
 }
}
    
function clearDistrictId(){
	var flag = true;
	if(flag)
	{
		document.getElementById("districtId").value = '';
		document.getElementById("buildingId").value = '';
	}
}
      
function clearBuildingId(){
	var flag = true;
	if(flag)
	{
		document.getElementById("buildingId").value = '';
		document.getElementById("doorId").value = '';
	}
}
  
function checkAll(name) {
	var el = document.getElementsByTagName('input');
	var len = el.length;
	for(var i=0; i<len; i++){
		if((el[i].type=="checkbox") && (el[i].name==name)){
			el[i].checked = true;
		}
	}
}
function clearAll(name){
	var el = document.getElementsByTagName('input');
	var len = el.length;
	for(var i=0; i<len; i++){
		if((el[i].type=="checkbox") && (el[i].name==name)){
			el[i].checked = false;
		}
	}
} 
function trim(str){
	return str.replace(/(^\s*)|(\s*$)/g,"");
}
function form_submit(){
	document.getElementById("form").submit();
}
function goto(){
	var arg = document.getElementById("page_goto").value;
	if(!checkIsInteger(arg)){
		arg = 1;
	}
	
	var areaId = document.getElementById('areaId').value;
    var districtId = document.getElementById('districtId').value;
    var buildingId = document.getElementById('buildingId').value;
    var url = "Page_changePage.action?requestPage="+arg+"&map=JspCmBuildingList";
    var href = url+"&areaId="+areaId+"&districtId="+districtId+"&buildingId="+buildingId;
    window.navigate(href);
}
function checkIsInteger(str)   {    
    if(/^(\-?)(\d+)$/.test(str))   
        return true;   
    else  
        return false;   
}
</script>
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
	img{
	 border: 0;
	}
body {
	margin-left: 3px;
	margin-top: 0px;
	margin-right: 3px;
	margin-bottom: 0px;
}
a{
	font-size: 12px;
	color: #3b6375;
}
.STYLE1 {
	color: #e1e2e3;
	font-size: 12px;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
	color: #344b50;
	font-size: 12px;
}
.STYLE21 {
	font-size: 12px;
	color: #3b6375;
}
.STYLE22 {
	font-size: 12px;
	color: #295568;
}
.submitStyle {background:url(images/del.gif);border:0px} 
</style>
<script type="text/javascript" language="javascript">
 function add()
 {
   var url="/mj/jsp/cm/building/add.jsp?districtId=";
   var districtId = document.getElementById('districtId').value;
   var areaId = document.getElementById('areaId').value;
   url = url + districtId+"&areaId="+areaId;
   location.href=url;
 }
  function editw(para)
 {
    
    var url = "Building_edit.action?id=";
    var areaId = document.getElementById('areaId').value;
    url = url +para+"&areaId="+areaId;
    location.href=url;
 }
 
  function changePage(para)
 {
   var areaId = document.getElementById('areaId').value;
   var districtId = document.getElementById('districtId').value;
   var buildingId = document.getElementById('buildingId').value;
   var href = para+"&areaId="+areaId+"&districtId="+districtId+"&buildingId="+buildingId;
   window.navigate(href);
   
 }
</script>
  </head>
<body>
<form name="searchForm" action="Search_searchList" method="post">
<input type="hidden" name="userId" value="<s:property value="userId"/>"/>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1">搜索</span></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
	<tr>
	<td>
		<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
			<tr>
        		<td width="33%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">区域</span></div></td>
        		<td width="33%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">片区</span></div></td>
        		<td width="33%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">机楼</span></div></td>
    		</tr>
    		<tr>
        		<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">
        			<table>
        				<s:select name="areaId"  onchange="searchForm.submit()" list="areaList" listKey="areaId" listValue="areaName" cssStyle="STYLE10" cssClass="STYLE10" headerValue="请选择区域" headerKey="" onclick='clearDistrictId()'/>
        			</table>
        		</div></td>
        		<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">
        			<table>
        				<s:select name="districtId" id="districtId" onchange="searchForm.submit()" list="districtList" listKey="districtId" listValue="districtName" headerValue="请选择片区" headerKey="" onclick='clearBuildingId()'/>
        			</table>
        		</div></td>
		        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">
		        	<table>
		        		<s:select name="buildingId" onchange="searchForm.submit()" list="buildingList" listKey="buildingId" listValue="buildingName" headerValue="请选择机楼" headerKey=""/>
		        	</table>
		        </div></td>  
      		</tr>
    	</table>
    </td>
  </tr>
</table>
</form>
<div align="center"><font color="red"><s:property value="errorMsg"/></font></div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1"> 机楼信息列表</span></td>
              </tr>
            </table></td>
            <td>
            	<div align="right">
            		<span class="STYLE1">
            		<%if(((Admin)request.getSession().getAttribute("admin")).getRole().equals("中心管理员")){ %>
              			<input type="checkbox" name="checkbox" value="" onclick="if(this.checked==true) { checkAll('id'); } else { clearAll('id'); }" />全选&nbsp;&nbsp;
              			<input type="image" src="images/add.gif" onClick="add()"/> 添加机楼&nbsp;&nbsp;
              			<input type="image" src="images/del.gif" id="_delete" name="method:delete" onClick="form_submit()" /> 删除&nbsp;&nbsp;
              		<%} %>
              		</span>
              		<span class="STYLE1">
              			&nbsp;
              		</span>
              	</div>
            </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
      <tr>
      <%if(((Admin)request.getSession().getAttribute("admin")).getRole().equals("中心管理员")){ %>
        <td width="5%" height="20" bgcolor="d3eaef" class="STYLE10"><div align="center">
          <input type="checkbox" name="checkbox" value="" onclick="if(this.checked==true) { checkAll('id'); } else { clearAll('id'); }" />
        </div></td>
        <%} %>
        <td width="20%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">机楼名称</span></div></td>
        <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">机楼地理位置</span></div></td>
        <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">机楼描述</span></div></td>
        <td width="20%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">基本操作</span></div></td>
      </tr>
      <form name="form" action="Building_delete" method="post">
      <s:iterator value="result" status="status">
      <tr>
      <%if(((Admin)request.getSession().getAttribute("admin")).getRole().equals("中心管理员")){ %>
        <td height="20" bgcolor="#FFFFFF"><div align="center">
          <input type="checkbox" name="id" value="<s:property value="BuildingId"/>"/>
        </div></td>
        <%} %>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="BuildingName"/></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="BuildingLocation"/></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="BuildingComment"/></div></td>
        <td height="20" bgcolor="#FFFFFF"><div align="center" class="STYLE21">
	    <%if(((Admin)request.getSession().getAttribute("admin")).getRole().equals("中心管理员")){ %>
	        <a href="Building_delete.action?id=<s:property value="BuildingId"/>&districtId=<s:property value="DistrictId"/>&areaId=<s:property value="AreaId"/>">删除</a> | 
	     <%} %>
        	<a href="Building_edit.action?id=<s:property value="BuildingId"/>&districtId=<s:property value="DistrictId"/>&areaId=<s:property value="AreaId"/>" >编辑</a> | 
        	<a href="Search_doorList.action?bid=<s:property value="BuildingId"/>&did=<s:property value="DistrictId"/>&aid=<s:property value="AreaId"/>">下属门禁</a>
        </div></td>
      </tr>
      </s:iterator>

    </table></td>
    <s:select name="areaId" list="areaList" listKey="areaId" listValue="areaName" id="areaId" style="display:none"/>
    <s:select name="districtId" id="districtId" list="districtList" listKey="districtId" listValue="districtName" style="display:none"/>
    </form>
  </tr>
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="33%"><div align="left"><span class="STYLE22">&nbsp;&nbsp;&nbsp;&nbsp;共有<strong><s:property value="page.listSize"/></strong> 条记录，当前第<strong><s:property value="page.currentPage"/></strong> 页，共 <strong><s:property value="page.totalPages"/></strong> 页</span></div></td>
        <td width="67%"><table width="312" border="0" align="right" cellpadding="0" cellspacing="0">
          <tr>
            <td width="49"><div align="center"><a href="javascript:changePage('Page_changePage.action?requestPage=1&map=JspCmBuildingList')"><img src="images/main_54.gif" width="45" height="15" /></a></div></td>
            <td width="49"><div align="center"><a href="javascript:changePage('Page_changePage.action?requestPage=<s:property value="page.prePage"/>&map=JspCmBuildingList')"><img src="images/main_56.gif" width="45" height="15" /></a></div></td>
            <td width="49"><div align="center"><a href="javascript:changePage('Page_changePage.action?requestPage=<s:property value="page.nextPage"/>&map=JspCmBuildingList')" ><img src="images/main_58.gif" width="45" height="15" /></a></div></td>
            <td width="49"><div align="center"><a href="javascript:changePage('Page_changePage.action?requestPage=<s:property value="page.totalPages"/>&map=JspCmBuildingList')"><img src="images/main_60.gif" width="45" height="15" /></a></div></td>
            <td width="37" class="STYLE22"><div align="center">转到</div></td>
            <td width="22"><div align="center">
              <input type="text" name="textfield" id="page_goto"  style="width:20px; height:15px; font-size:12px; border:solid 1px #7aaebd;"/>
            </div></td>
            <td width="22" class="STYLE22"><div align="center">页</div></td>
            <td width="35"><img src="images/main_62.gif" width="26" height="15" onClick="goto()"/></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>
